/********************************************************************



Write Date: 2011/03/28
Author: Deng Nianchen
>>>> 
	
*********************************************************************/
#ifndef SOCKET_CLIENT_H
#define SOCKET_CLIENT_H
#include <string>
#include <ooputils/ByteStream.h>
#include <ooputils/Ptr.hpp>
#include "Global.hpp"



_OOPNETWORK_BEGIN



class SocketManager;



class _EXPORT_NETWORK_CLASS SocketClient : public OOPUtils::OOPObject
{

  friend class SocketManager;

private:

  SOCKET _connSock;

  char * _buffer;

  size_t _bufferSize;

  bool _isOpen;

  bool _isBlockMode;

  SocketClient (bool isBlockMode = false);

public:


  ~SocketClient ();

  void connectTo (const std::string & ip, unsigned short port);

  void sendData (const OOPUtils::ByteStream & data) const;

  OOPUtils::OOPPtr< OOPUtils::ByteStream > receiveData () const;

  void closeConnection ();

};


_OOPNETWORK_END

#endif